import {
	createStore
} from 'vuex'

export default createStore({
	state: {
		//tips Url
		TipsUrl: 'adaptTips/tipContents/test.vue',

		AdaptTips: {
			dataArr: ["$a3654", "$a3655", "$a3656"],
			"$a3654": {
				"props": ["name", "type", "text", "style"],
				"name": "将军",
				"type": "text",
				"text": "对面笑",
				"style": "color:red;"
			},
			"$a3655": {
				"props": ["name", "type", "text", "style"],
				"name": "曲奇饼干",
				"type": "text",
				"text": "26元",
				"style": "color:#a35ba0"
			},
			"$a3656": {
				"props": ["name", "type", "url", "style"],
				"name": "曲奇饼干",
				"type": "img",
				"url": "https://www.quyuan88.com/UploadFiles/FCK/2019-07/6369949485360967815421115.png",
				"style": "width:200px;height:200px;"
			}
		},
		ExtendApp: {},
		currentDisplayID: '#6673',
		DisplayIDArray: ['#6672',
			'#6673',
			'#6674',
			'#6675',
			'#6676'
		],
		user_reload_id: '#6636',
		compK_V: {
			'#6635': 'image',
			'#6636': 'calligraphy',
			'#77452': 'music',
			'#43321': 'draw'
		}
	},
	mutations: {
		reloadContentID(state, id) {
			// console.log(id);
			state.user_reload_id = id
		},
		setTergetID(state, [ob, index]) {
			//tostring 类型检测 a 数据源 type 数据类型 （不分大小写）
			function toStringTypeCheck(a, type) {
				if (type == undefined) {
					return false
				} else if (type.toLowerCase() == "any") {
					return true
				}
				// console.log(toString.call(a).slice(8, -1))
				return toString.call(a).slice(8, -1).toLowerCase() == type.toLowerCase()
			}

			if (toStringTypeCheck(ob, "Array")) {

				state.DisplayIDArray = ob
				console.log(index);
				state.currentDisplayID = index > -1 ? state.DisplayIDArray[index] : state.DisplayIDArray[0]

			} else if (toStringTypeCheck(ob, "String")) {

				state.DisplayIDArray = ob
				state.currentDisplayID = state.DisplayIDArray

			}
		}
	},
	actions: {
		// reloadContentID(context, payload) {
		// 	context.commit('reloadContentID', payload)
		// }
	},
	modules: {}
})
